<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>view/workArea/onlineService/callRecord</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<link rel="stylesheet" href="../../../css/mui.min.css">
		<link rel="stylesheet" href="../../../css/global.css">
		<link rel="stylesheet" href="../../../css/style.css">
		<link rel="stylesheet" href="../../../css/mui.picker.css">
		<link rel="stylesheet" href="../../../css/mui.poppicker.css">

		<style>
			.mui-radio input[type=radio] {
				left: 0;
				top: 11px;
			}

			.mui-checkbox label,
			.mui-radio label {
				padding-left: 38px;
				font-size: 14px;
				color: #333333;
				padding-right: 0;
			}

			.d_ipt {
				width: 65% !important;
			}

			input[type=number],
			input[type=text] {
				padding: 10px 15px !important;
			}

			.clum_textarea {
				margin: 0 20px;
				font-size: 16px;
				color: #999999;
				border-bottom: 1px solid #e8e8e8;
				height: 100px;
				overflow: hidden;
			}

			.clum_textarea .name {
				float: left;
				display: block;
				line-height: 50px;
			}

			.clum_textarea textarea {
				text-align: right;
				float: right;
				height: 100px;
				min-height: 100px;
				padding: 14px 0;
			}
		</style>
		<style>
			.sel{
				font-size: 12px;
				margin-left: 10px;
				color: #ffffff;
				background: #ea1e1a;
				height: 20px;
				line-height: 12px !important;
				margin-top: 15px;
				border-radius: 5px;
				padding: 5px;
			}
			.selectxx{
				position: absolute;
				right: 10px;
			}
			.mui-btn-select{
				line-height: 3.125rem;
				color: #a9a9a9;
			    padding-right: 0.9375rem;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 id="title" class="mui-title">电话解决记录</h1>
		</header>
		<div class="mui-content">
			<div class="details_con" id="form_info">
				<div class="clum">
					<span class="name">联系人<em class="t_red">*</em></span>
					<input type="text" class="d_ipt" name="Cont" required="required" maxlength="100" placeholder="请输入联系人" />
				</div>
				<div class="clum">
					<span class="name">手机号<em class="t_red">*</em></span>
					<input type="text" class="d_ipt" name="Mobile" required="required" maxlength="100" placeholder="请输入手机号" />
				</div>
				<div class="clum">
					<span class="name">序列号</span>
					<input type="text" class="d_ipt" id="Serial" name="Serial" maxlength="100" placeholder="请输序列号" />
					<button class="sel selectxx" id="serialSelectBtn">查询</button>
				</div>

				<div class="clum">
					<span class="name">客户名称</span>
					<input type="text" class="d_ipt" id="CustName" name="CustName" maxlength="100" placeholder="请输入客户名称" />
				</div>
				<div class="clum">
					<span class="name">设备型号</span>
					<input type="text" class="d_ipt" id="EqModel" name="EqModel" maxlength="100" placeholder="请输入设备型号" />
				</div>
				<div class="clum">
					<span class="name">问题分类<em class="t_red">*</em></span>
					<input type="hidden" id="queType" name="QueType" required="required" placeholder="请选择问题分类" />
					<span class="txt">
						<button id='queTypeSel' class="mui-btn-select" type='button'>请选择问题分类</button>
					</span>
					<!-- <input type="text" class="d_ipt" name="QueType" required="required" placeholder="请输入问题分类" /> -->
				</div>
				<div class="clum">
					<span class="name">是否解决<em class="t_red">*</em></span>
					<input type="hidden" id="isSolved" name="IsSolved" required="required" placeholder="请选择是否解决" />
					<span class="txt">
						<button id='isSolvedSel' class="mui-btn-select" type='button'>请选择是否解决</button>
					</span>
				</div>
				<div class="clum">
					<span class="name">时长(h)<em class="t_red">*</em></span>
					<input type="number" class="d_ipt" name="Hours" required="required" maxlength="5" placeholder="请输入时长" />
				</div>
				<div class="clum autoHeight">
					<span class="name">备注</span>
					<div class="clear"></div>
					<textarea class="textarea" name="Remarks" required="required" maxlength="1000" placeholder="请输入备注"></textarea>
				</div>
			</div>
			<div class="btn_box">
				<span class="fl" id="cancelBtn">取消</span>
				<span class="fr red" id="submitBtn">保存</span>
			</div>
			<div style="height: 50px;"></div>
		</div>

		<!-- js代码 start -->

		<!-- 基础js start -->
		<script src="../../../js/mui.min.js"></script>
		<script src="../../../js/utils/h.js"></script>
		<script src="../../../js/constant.js"></script>
		<script src="../../../js/common.js"></script>
		<script src="../../../js/utils/base64.js"></script>
		<script src="../../../js/utils/md5.js"></script>
		<script src="../../../js/utils/sortMap.js"></script>
		<script src="../../../js/utils/http.js"></script>
		<script src="../../../js/app.js"></script>
		<script src="../../../js/mui.picker.js"></script>
		<script src="../../../js/mui.poppicker.js"></script>
		<!-- 基础js end -->


		<script type="text/javascript" charset="utf-8">
			(function($, doc) {
				$.init();

				$.plusReady(function() {
					var self = plus.webview.currentWebview();
					
					h('#cancelBtn').tap(function() {
						self.close();
					});
					h('#submitBtn').tap(function() {
						var formObj = {}; //POST参数对象
						var subFlag = true;
						mui("#form_info input").each(function(index, item) {
							var value = item.value;
							var name = item.getAttribute("name");
							var required = item.getAttribute("required");
							if (required && !value) {
								subFlag = false;
								app.toast(item.getAttribute("placeholder"));
								return false;
							}

							if(name == 'Mobile' && !(/^[1][3,4,5,7,8][0-9]{9}$/.test(value))){
								subFlag = false;
								app.toast("请输入有效手机号码");  
								return false; 
							}
							formObj[name] = value; //参数赋值
						});
						if (subFlag) {
							var enginner_id = app.getUser().enginnerId;
							formObj["enginner_id"] = enginner_id;
							// console.log(JSON.stringify(formObj));
							app.showWaiting('加载中...')
							
							ajaxPost(BASE_URL + "cc/onlineService/submitCallRecordInfo", formObj, function(data) {
								app.closeWaiting()
								// console.log(JSON.stringify(data));
								if (data.code == 200) { //查询成功
									app.toast("保存成功");
									// 返回上一页
									self.close();
								} else { //查询失败
									app.toast("保存失败");
								}
							}, function(errorMsg) {
								app.closeWaiting()
								app.toast(JSON.stringify(errorMsg))
							});
						}
					});

					h('#serialSelectBtn').tap(function() {
						var serial = h("#Serial").val();
						if (serial) {
							cleanInput()
							ajaxGet(BASE_URL + "cc/onlineService/getUserEqInfoBySerial", {
								"serial": serial
							}, function(data) {
								// console.log(JSON.stringify(data))
								if (data.code == 200) { //查询成功
									var res = JSON.parse(data.data);
									if (res.status && res.status == 1) {
										var info = res.record[0];
										h("#CustName").val(info.CustName);
										h("#EqModel").val(info.Model);
									} else {
										app.toast(res.message);
									}
								} else { //查询失败
									app.toast(data.msg)
								}
							}, function(errorMsg) {
								console.log(JSON.stringify(errorMsg))
							});
						} else {
							app.toast("请输序列号");
						}
					});
					
					// 问题分类
					h('#queTypeSel').tap(function() {
						document.activeElement.blur();
						app.hideSoftKeybord();
						var userPicker = new $.PopPicker();
						userPicker.setData([{value: '5', text: '软件问题'},{value: '6', text: '硬件问题'},{value: '7', text: '应用问题'},{value: '8', text: '其他问题'}]);
						userPicker.show(function(items) {
							h('#queTypeSel').html(items[0].text)
							h('#queType').val(items[0].value)
							userPicker.dispose()
						});
					});
					
					// 是否解决
					h('#isSolvedSel').tap(function() {
						document.activeElement.blur();
						app.hideSoftKeybord();
						var userPicker = new $.PopPicker();
						userPicker.setData([{value: '0', text: '否'},{value: '1', text: '是'}]);
						userPicker.show(function(items) {
							h('#isSolvedSel').html(items[0].text)
							h('#isSolved').val(items[0].value)
							userPicker.dispose()
						});
					});
				
				});

			}(mui, document));
			
			// 清空输入框
			function cleanInput() {
				h("#CustName").val("");
				h("#EqModel").val("");
			}
			
		</script>

		<!-- js代码 end -->

	</body>

</html>
